import 'dart:ui';

import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

class AwakText {
  // 自定义字体
  static const String poppins = 'Poppins';
  static const String pingFangSC = 'PingFang SC';
  static const String baloo2 = 'Baloo 2';

  // 自定义样式
  // 标题
  static TextStyle titleStyle = TextStyle(
    color: const Color(0xFF000000),
    fontFamily: poppins,
    fontSize: 20.sp,
    fontWeight: FontWeight.w500,
  );

  // 正文
  static TextStyle body16Style = TextStyle(
    color: const Color(0xFF000000),
    fontFamily: poppins,
    fontSize: 16.sp,
    fontWeight: FontWeight.w400,
  );
  static TextStyle body18Style = TextStyle(
    color: const Color(0xFF000000),
    fontFamily: poppins,
    fontSize: 18.sp,
    fontWeight: FontWeight.w400,
  );
  static TextStyle body14Style = TextStyle(
    color: const Color(0xFF000000),
    fontFamily: poppins,
    fontSize: 14.sp,
    fontWeight: FontWeight.w400,
  );

  // 苹果登录按钮
  static TextStyle appleStyle = TextStyle(
    color: Colors.white,
    fontFamily: pingFangSC,
    fontSize: 18.sp,
    fontWeight: FontWeight.w500,
  );

  // 新用户注册
  static TextStyle newUserStyle = TextStyle(
    color: const Color(0xFF000000),
    fontFamily: baloo2,
    fontSize: 12.sp,
    fontWeight: FontWeight.w400,
  );
  static TextStyle signUpStyle = TextStyle(
    color: const Color(0xFF84BD93),
    fontFamily: baloo2,
    fontSize: 12.sp,
    fontWeight: FontWeight.w400,
  );


  // 隐私政策
  static TextStyle privacyStyle = TextStyle(
    color: const Color(0xFF9A9A9A),
    fontFamily: pingFangSC,
    fontSize: 10.sp,
    fontWeight: FontWeight.w400,
  );
  static TextStyle privacyOntapStyle = TextStyle(
    color: const Color(0xFF000000),
    fontFamily: pingFangSC,
    fontSize: 10.sp,
    fontWeight: FontWeight.w400,
    decoration: TextDecoration.underline,
    decorationColor: const Color(0xFF000000),
    decorationThickness: 1,
  );


}

// 设备适配工具类
class DeviceUtils {
  static bool isTablet(BuildContext context) {
    final screenWidth = MediaQuery.of(context).size.width;
    final screenHeight = MediaQuery.of(context).size.height;
    final shortestSide = screenWidth < screenHeight ? screenWidth : screenHeight;
    
    // 降低平板检测阈值：宽度小于400px 或者 最短边小于400px
    return screenWidth < 400 || shortestSide < 400;
  }
  
  static bool isPhone(BuildContext context) {
    final screenWidth = MediaQuery.of(context).size.width;
    final screenHeight = MediaQuery.of(context).size.height;
    final shortestSide = screenWidth < screenHeight ? screenWidth : screenHeight;
    
    // 手机检测：宽度大于等于400px 且 最短边大于等于400px
    return screenWidth >= 400 && shortestSide >= 400;
  }
  
  static double getResponsiveWidth(BuildContext context, {double phoneWidth = 311, double tabletRatio = 0.4}) {
    final screenWidth = MediaQuery.of(context).size.width;
    if (isTablet(context)) {
      return screenWidth * tabletRatio;
    }
    return phoneWidth.w;
  }
  
  static double getResponsiveHeight(BuildContext context, {double phoneHeight = 433, double tabletRatio = 0.6}) {
    final screenHeight = MediaQuery.of(context).size.height;
    if (isTablet(context)) {
      return screenHeight * tabletRatio;
    }
    return phoneHeight.h;
  }
}